/*
 * Copyright (c) 2021.版权所有高金磊
 */

package 领扣算法.A简单题.是否所有1都至少相隔k个元素;

public class Main {
    public static void main(String arg[]) {//main--来自高金磊

        new Main().kLengthApart(new int[]{1, 0, 0, 0, 1, 0, 0, 1}, 2);
    }

    public boolean kLengthApart(int[] nums, int k) {
        int n = k;
        for (int num : nums) {
            if (num == 1) {
                if (n < k)
                    return false;
                n = 0;
            } else
                n++;
        }
        return true;
    }
}
